from rest_framework.mixins import ListModelMixin, RetrieveModelMixin


from utils.common_response import APIResponse


class CommonListModelMixin(ListModelMixin):

    def list(self, request, *args, **kwargs):
        res = super().list(request, *args, **kwargs)
        # print(res.data)
        for data in res.data:
            data['image'] = 'http://127.0.0.1:8000/media/'+ data['image']
            #"http://127.0.0.1:8000/media/banner/banner_1.png"
        # print(res.data)
        return APIResponse(code=200,data=res.data)


class CommonRetrieveModelMixin(RetrieveModelMixin):
    def retrieve(self, request, *args, **kwargs):
        res = super().retrieve(request, *args, **kwargs)
        return APIResponse(data=res.data)
